﻿Imports Microsoft.VisualBasic

Namespace My

    <Serializable()> _
    Public Structure UserType
        '公務帳號
        Public Shared Employee As New UserType("E")
        '環保志工
        Public Shared Volunteer As New UserType("V")
        '民間團體帳號
        Public Shared Person As New UserType("P")

        Private internalValue As String

        Public ReadOnly Property Value() As String
            Get
                Return Me.internalValue
            End Get
        End Property

        Public Sub New(ByVal value As String)
            Me.internalValue = value
        End Sub

        Public Shared Operator =(ByVal obj1 As UserType, ByVal obj2 As UserType) As Boolean
            If obj1.Value = obj2.Value Then
                Return True
            Else
                Return False
            End If
        End Operator

        Public Shared Operator <>(ByVal obj1 As UserType, ByVal obj2 As UserType) As Boolean
            If obj1.Value <> obj2.Value Then
                Return True
            Else
                Return False
            End If
        End Operator

        Public Shared Operator =(ByVal obj1 As String, ByVal obj2 As UserType) As Boolean
            Return New UserType(obj1) = obj2
        End Operator

        Public Shared Operator <>(ByVal obj1 As String, ByVal obj2 As UserType) As Boolean
            Return New UserType(obj1) <> obj2
        End Operator

        Public Overrides Function ToString() As String
            Return Me.Value
        End Function

    End Structure
End Namespace

